package com.aternity.geolocations.firebird;

import au.com.bytecode.opencsv.CSVReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Daniel Orr
 */
public class TableauNameCache {

    private final Map<Integer, String> cache = new HashMap<>();

    public TableauNameCache(File f) throws Exception {
        try (CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(f), "UTF-8"))) {
            String[] line;
            while ((line = csvReader.readNext()) != null) {
                cache.put(Integer.parseInt(line[0]), line[1]);
            }
        }
    }

    public String getEntityName(Integer countryID) {
        return cache.get(countryID);
    }

}
